<?php
/**
 * Enter description here...
 *	
 * STATUS_DISABLE 0 
 * STATUS_ABLE 1 
 */
class Purview extends CActiveRecord {
	public static function model($className = __CLASS__) {
		return parent::model ( $className );
	}
	
	public function tableName() {
		return '{{purview}}';
	}
	
	public function rules() {
		return array (
			
			array (
				
				'title,path,pid', 
				'required', 
				'message' => '不能为空' 
			) 
		);
	}
	
	public function relations() {
		return array ();
	}
	
	public function attributeLabels() {
		return array (
			
			'id' => 'id', 
			'title' => 'title', 
			'path' => 'path', 
			'pid' => 'pid', 
			'orders' => 'orders', 
			'state' => 'state' 
		);
	}
	public function getPurview() {
		$ret = $this->findAll ( array (
			
			"condition" => "pid=0 and state=1", 
			"order" => "orders" 
		) );
		$rows = CommonFunc::YiiobjectToArray ( $ret, "all" );
		return $rows;
	}
	public function getPurByPid($pid,$state=1) {
		if($state == "all"){
			$state = "and state in (0,1)";
		}else{
			$state = "and state = 1";
		}
		$ret = $this->findAll ( array (
			
			"condition" => "pid='$pid' $state", 
			"order" => "orders" 
		) );
		$rows = CommonFunc::YiiobjectToArray ( $ret, "all" );
		return $rows;
	}

}
?>
